package util;

/**
 * @className: PathUtil
 * @author: ocxz1
 * @date: 2025/3/11 下午6:41
 * @Version: 1.0
 * @description: tmp-study
 */
public class PathUtil {

    public static String getPath(String path) {
        if (path.startsWith("/")) {
            path = path.substring(1);
        }
        if (path.endsWith("/")) {
            path = path.substring(0, path.length() - 1);
        }
        return path;
    }

    public static String joinPath(String... paths) {
        StringBuilder sb = new StringBuilder();
        for (String path : paths) {
            if (path != null && !path.isEmpty()) {
                sb.append(getPath(path)).append("/");
            }
        }
        return "/" + sb.toString();
    }
}
